package com.pengtu.gsj.service.impl.lzgl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.lzgl.RoadInfoSysDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.lzgl.RoadInfoSys;
import com.pengtu.gsj.service.lzgl.RoadInfoSysService;
import com.pengtu.gsj.service.system.SystemManageService;

@Service
@Transactional
public class RoadInfoSysServiceImpl implements RoadInfoSysService {

	@Autowired
	public RoadInfoSysDao roadInfoSysDao;
	@Autowired
	public SystemManageService systemManageService;
	
	@Override
	public RoadInfoSys getRoadInfoSysById(String id) {
		return roadInfoSysDao.get(id);
	}

	@Override
	public Page<RoadInfoSys> findRoadInfoSys(Page<RoadInfoSys> page, final QueryFilter queryFilter){
		return roadInfoSysDao.findPage(page, queryFilter);
	}

	@Override
	public void saveRoadInfoSys(RoadInfoSys roadInfoSys) {
		roadInfoSysDao.save(roadInfoSys);
	}

	@Override
	public void  delateRoadInfoSys(RoadInfoSys roadInfoSys){
		if(roadInfoSys.getAttachments() != null){
			for(Attachment attachment : roadInfoSys.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		roadInfoSysDao.delete(roadInfoSys);
	}
}
